{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-05-22T08:16:04.912363Z",
     "start_time": "2025-05-22T08:16:04.867601Z"
    }
   },
   "source": [
    "from models.GDN.GDN_interface import detect_anomalies\n",
    "\n",
    "result = detect_anomalies('msl',r'../data/raw/msl/test.csv',[32,3,7])\n",
    "print(result)"
   ],
   "outputs": [
    {
     "ename": "Exception",
     "evalue": "检测过程出错: [Errno 2] No such file or directory: './data/raw/msl/list.txt'",
     "output_type": "error",
     "traceback": [
      "\u001B[31m---------------------------------------------------------------------------\u001B[39m",
      "\u001B[31mFileNotFoundError\u001B[39m                         Traceback (most recent call last)",
      "\u001B[36mFile \u001B[39m\u001B[32m~/Documents/Code/Python/TSAD_Demo/models/GDN/anomaly_detector.py:206\u001B[39m, in \u001B[36mdetect_anomalies\u001B[39m\u001B[34m(model_name, file_path, params)\u001B[39m\n\u001B[32m    205\u001B[39m \u001B[38;5;66;03m# 在参数更新后再初始化模型\u001B[39;00m\n\u001B[32m--> \u001B[39m\u001B[32m206\u001B[39m \u001B[43minit_model\u001B[49m\u001B[43m(\u001B[49m\u001B[43mmodel_name\u001B[49m\u001B[43m)\u001B[49m\n\u001B[32m    208\u001B[39m \u001B[38;5;66;03m# 进行预测\u001B[39;00m\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~/Documents/Code/Python/TSAD_Demo/models/GDN/anomaly_detector.py:40\u001B[39m, in \u001B[36minit_model\u001B[39m\u001B[34m(model_name)\u001B[39m\n\u001B[32m     39\u001B[39m \u001B[38;5;66;03m# 加载特征映射和图结构\u001B[39;00m\n\u001B[32m---> \u001B[39m\u001B[32m40\u001B[39m feature_map = \u001B[43mget_feature_map\u001B[49m\u001B[43m(\u001B[49m\u001B[43mdataset\u001B[49m\u001B[43m)\u001B[49m\n\u001B[32m     41\u001B[39m fc_struc = get_fc_graph_struc(dataset)\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~/Documents/Code/Python/TSAD_Demo/models/GDN/util/net_struct.py:2\u001B[39m, in \u001B[36mget_feature_map\u001B[39m\u001B[34m(dataset)\u001B[39m\n\u001B[32m      1\u001B[39m \u001B[38;5;28;01mdef\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34mget_feature_map\u001B[39m(dataset):\n\u001B[32m----> \u001B[39m\u001B[32m2\u001B[39m     feature_file = \u001B[38;5;28;43mopen\u001B[39;49m\u001B[43m(\u001B[49m\u001B[33;43mf\u001B[39;49m\u001B[33;43m'\u001B[39;49m\u001B[33;43m./data/raw/\u001B[39;49m\u001B[38;5;132;43;01m{\u001B[39;49;00m\u001B[43mdataset\u001B[49m\u001B[38;5;132;43;01m}\u001B[39;49;00m\u001B[33;43m/list.txt\u001B[39;49m\u001B[33;43m'\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[33;43m'\u001B[39;49m\u001B[33;43mr\u001B[39;49m\u001B[33;43m'\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[32m      3\u001B[39m     feature_list = []\n",
      "\u001B[31mFileNotFoundError\u001B[39m: [Errno 2] No such file or directory: './data/raw/msl/list.txt'",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001B[31mException\u001B[39m                                 Traceback (most recent call last)",
      "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[3]\u001B[39m\u001B[32m, line 3\u001B[39m\n\u001B[32m      1\u001B[39m \u001B[38;5;28;01mfrom\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01mmodels\u001B[39;00m\u001B[34;01m.\u001B[39;00m\u001B[34;01mGDN\u001B[39;00m\u001B[34;01m.\u001B[39;00m\u001B[34;01manomaly_detector\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;28;01mimport\u001B[39;00m detect_anomalies\n\u001B[32m----> \u001B[39m\u001B[32m3\u001B[39m result = \u001B[43mdetect_anomalies\u001B[49m\u001B[43m(\u001B[49m\u001B[33;43m'\u001B[39;49m\u001B[33;43mmsl\u001B[39;49m\u001B[33;43m'\u001B[39;49m\u001B[43m,\u001B[49m\u001B[33;43mr\u001B[39;49m\u001B[33;43m'\u001B[39;49m\u001B[33;43m../data/raw/msl/test.csv\u001B[39;49m\u001B[33;43m'\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m[\u001B[49m\u001B[32;43m32\u001B[39;49m\u001B[43m,\u001B[49m\u001B[32;43m3\u001B[39;49m\u001B[43m,\u001B[49m\u001B[32;43m7\u001B[39;49m\u001B[43m]\u001B[49m\u001B[43m)\u001B[49m\n\u001B[32m      4\u001B[39m \u001B[38;5;28mprint\u001B[39m(result)\n",
      "\u001B[36mFile \u001B[39m\u001B[32m~/Documents/Code/Python/TSAD_Demo/models/GDN/anomaly_detector.py:212\u001B[39m, in \u001B[36mdetect_anomalies\u001B[39m\u001B[34m(model_name, file_path, params)\u001B[39m\n\u001B[32m    210\u001B[39m     \u001B[38;5;28;01mreturn\u001B[39;00m result\n\u001B[32m    211\u001B[39m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mException\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m e:\n\u001B[32m--> \u001B[39m\u001B[32m212\u001B[39m     \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mException\u001B[39;00m(\u001B[33mf\u001B[39m\u001B[33m\"\u001B[39m\u001B[33m检测过程出错: \u001B[39m\u001B[38;5;132;01m{\u001B[39;00m\u001B[38;5;28mstr\u001B[39m(e)\u001B[38;5;132;01m}\u001B[39;00m\u001B[33m\"\u001B[39m)\n",
      "\u001B[31mException\u001B[39m: 检测过程出错: [Errno 2] No such file or directory: './data/raw/msl/list.txt'"
     ]
    }
   ],
   "execution_count": 3
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "7f15f133d6c41d0f"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
